package edu.cuit.avatar.concurrent;

/**
 * @author <a href="mailto:1020zhaodan@163.com">Adan</a>
 * @version 1.0
 * @date 2025/7/17 15:18
 */
public class DaemonTest {
    private static class You implements Runnable{
        @Override
        public void run() {
            for(var i = 1; i <= 365 * 200; i++)
                System.out.println("happy life...");
            System.out.println("o..............");
        }
    }

    private static class God implements Runnable{
        @Override
        public void run() {
            for(;;)
                System.out.println("God bless you...");
        }
    }

    public static void main(String[] args) {
        //创建用户线程
        Thread thread = new Thread(new You());
        thread.start();

        thread = null; //停止用户线程

        //创建守护线程
        Thread thread2 = new Thread(new God());
        thread2.setDaemon(true);

        thread2.start();
    }
}
